package com.amc.common.utils;

import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * 收集器工具类
 *
 * @author ZhangXX
 * @date @2023/6/28 8:50
 */
public class CollectionUtil {

    /**
     * 排序收集
     * @param c
     * @param <T>
     * @return
     */
    public static <T> Collector<T, ?, List<T>> toSortedList(Comparator<? super T> c) {
        return Collectors.collectingAndThen(Collectors.toList(), list -> list.stream().sorted(c).collect(Collectors.toList()));
    }


}
